VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmAltReturnAddrEdit 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Add/Edit/Delete Alternate Return Addresses"
   ClientHeight    =   5310
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10095
   Icon            =   "frmAltReturnAddrEdit.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   5310
   ScaleWidth      =   10095
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Close"
      Height          =   315
      Left            =   5340
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   4860
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdDelete 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Delete All"
      Height          =   315
      Left            =   3540
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   4860
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Modify Address Information"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   4515
      Left            =   240
      TabIndex        =   2
      Top             =   180
      Width           =   9615
      Begin MSDataGridLib.DataGrid grdAddresses 
         Height          =   3795
         Left            =   300
         TabIndex        =   3
         TabStop         =   0   'False
         ToolTipText     =   "To Delete an Address, highlight a row and press the Delete button."
         Top             =   420
         Width           =   8955
         _ExtentX        =   15796
         _ExtentY        =   6694
         _Version        =   393216
         HeadLines       =   2
         RowHeight       =   15
         TabAction       =   2
         WrapCellPointer =   -1  'True
         AllowAddNew     =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Defined Addresses"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
   End
End
Attribute VB_Name = "frmAltReturnAddrEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim m_rsAddresses As New ADODB.Recordset     'Module level recordset tied to grdAddresses
'---------------------------------------------------------------------------------------
' Procedure : cmdClose_Click()
' DateTime  : 8/31/2004
' Purpose   : Updates Commodity combo on Intl tab of frmShip then hides form
'---------------------------------------------------------------------------------------
'
Private Sub cmdClose_Click()
    On Error GoTo EH
    g_strErrorLocation = "frmAddressEdit:cmdClose_Click"
    
    Call LoadAddrIDCombo(frmSetup.cboAddrID, frmSetup.cboAddrID)
    Me.Hide
    frmShip.SetFocus

    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdDelete_Click()
' DateTime  : 8/31/2004
' Purpose   : Verifes user wished to delete all defined Addresses, if yes calls sub to
'             delete all records in Commodities table and updates the grdAddresses.
'---------------------------------------------------------------------------------------
'
Private Sub cmdDelete_Click()
    Dim intRet As Integer

    On Error GoTo EH
    g_strErrorLocation = "frmAddressEdit:cmdDelete_Click"
    
    intRet = MsgBox("Are you sure you wish to delete all defined Addresses?", vbYesNo, "Confirm Delete All")
    If intRet = vbYes Then
        Call DeleteAllAddresses
        Call UpdateAddressesGrid
    End If

    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Activate()
' DateTime  : 7/7/2004
' Purpose   : Call routine to load Commodities into datagrid whenever the form is the
'             active form.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Activate()
    On Error GoTo EH
    g_strErrorLocation = "frmAddressEdit:Form_Activate"
        
    Call UpdateAddressesGrid
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Deactivate()
' DateTime  : 7/7/2004
' Purpose   : Closes module level recordset and sets it to nothing.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Deactivate()
    On Error GoTo EH
    g_strErrorLocation = "frmAddressEdit:Form_Deactivate"
        
    If m_rsAddresses.State = adStateOpen Then m_rsAddresses.Close
    Set m_rsAddresses = Nothing
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : UpdateAddressesGrid()
' DateTime  : 8/31/2004
' Purpose   : Update the Commodities grid and set column headings
' Call from : Form_Activate, cmdDelete_Click
'---------------------------------------------------------------------------------------
'
Public Sub UpdateAddressesGrid()
    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmCommoditiesEdit:UpdateCommoditiesGrid"
    
    'Select everything from DIMs table
    strQuery = "SELECT * FROM AltReturnAddr"
    'If already open, close recordset
    If m_rsAddresses.State = adStateOpen Then m_rsAddresses.Close
    'Execute query
    m_rsAddresses.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic

    Set grdAddresses.DataSource = m_rsAddresses
    With grdAddresses
        .ClearFields
        .ReBind
        .Columns(0).Caption = "Address ID"
        .Columns(1).Caption = "Company"
        .Columns(2).Caption = "Contact"
        .Columns(3).Caption = "Addr1"
        .Columns(4).Caption = "Addr2"
        .Columns(5).Caption = "City"
        .Columns(6).Caption = "St"
        .Columns(7).Caption = "Zip"
        .Columns(8).Caption = "Country"
        .Columns(9).Caption = "Phone"
    End With
    
Release:
    Set m_rsAddresses = Nothing
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release
     
End Sub

'---------------------------------------------------------------------------------------
' Procedure : DeleteAllAddresses()
' DateTime  : 8/31/2004
' Purpose   : Deletes all defined Addresses
'---------------------------------------------------------------------------------------
'
Public Sub DeleteAllAddresses()
    
    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmAddressesEdit:DeleteAllAddresses"
    
    'Build and execute the delete query
    strQuery = "DELETE FROM AltReturnAddr"
    g_connFSMSClient.Execute strQuery
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : grdAddresses_AfterColUpdate()
' DateTime  : 8/31/2004
' Purpose   : This commits the changes immediately after a column has been updated.
'             This keeps users from getting "Operation not allowed in this context" error.
'---------------------------------------------------------------------------------------
'
Private Sub grdAddresses_AfterColUpdate(ByVal ColIndex As Integer)
    On Error GoTo EH
    g_strErrorLocation = "frmAddressesEdit:grdAddresses_AfterColUpdate"
    
    If grdAddresses.Bookmark >= 0 Then
        grdAddresses.Bookmark = grdAddresses.Bookmark
    End If
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
